package cn.edu.lingnan.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.lingnan.dao.StudentDAO;
import cn.edu.lingnan.dto.Student;

public class RegisterServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String sId = req.getParameter("sId");
		String sName = req.getParameter("sName");
		String sPassword= req.getParameter("sPassword");
		int sSuper = Integer.parseInt(req.getParameter("sSuper"));
		Student s = new Student();
		s.setsId(sId);
		s.setsName(sName);
		s.setsPassword(sPassword);
		s.setsSuper(sSuper);
		StudentDAO sd = new StudentDAO();
		int flag= sd.insertIntoStu(s);
		if(flag==1){
			resp.sendRedirect(req.getContextPath()+"/index.html");
		}
		else{
			resp.sendRedirect(req.getContextPath()+"/register.html");
		}
	}
}
